import Vue from 'vue'
import VueRouter from 'vue-router'


Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: () => import('../views/Manage.vue'),
    redirect: "/home",
    children: [
      {path: 'home', name: '首页', component: () => import('../views/Home.vue')},
      {path: 'user', name: '用户管理', component: () => import('../views/User.vue')},
      {path: 'Person', name: '个人信息', component: () => import('../views/Person.vue')},
      {path: 'file', name: '文件管理', component: () => import('../views/File.vue')},
      {path: 'selfcheck', name: '故障自检', component: () => import('../views/SelfCheck.vue')},
      {path: 'part', name: '零件管理', component: () => import('../views/Part.vue')},
      {path: 'addPart', name: '新增零件', component: () => import('../views/AddPart.vue')},
      {path: 'order', name: '所有订单', component: () => import('../views/Order.vue')},
      {path: 'myOrder', name: '我的订单', component: () => import('../views/MyOrder.vue')},
      {path: 'createOrder', name: '创建订单', component: () => import('../views/CreateOrder.vue')},
      {path: 'repairTask', name: '所有维修任务', component: () => import('../views/RepairTask.vue')},
      {path: 'myRepairTask', name: '我的维修任务', component: () => import('../views/MyRepairTask.vue')},
      {path: 'pool', name: '任务池', component: () => import('../views/Pool.vue')},
      {path: 'userAndRole', name: '用户角色配置', component: () => import('../views/UserAndRole.vue')},
      {path: 'allRole', name: '所有角色', component: () => import('../views/AllRole.vue')},
    ]
  },

  {
    path: '/about',
    name: 'about',
    component: () => import('../views/About.vue')
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('../views/Login.vue')
  },
  {
    path: '/register',
    name: 'Register',
    component: () => import('../views/Register.vue')
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

router.beforeEach((to,from,next)=>{
  localStorage.setItem("currentPathName",to.name) //设置当前的路由名称
  next()
})

export default router
